// 引入axios

import ajax from './ajax'
import mockAjax from './mockAjax'

//发送请求
//获取三级分类
export const reqCategoryListData = () => ajax.get('/product/getBaseCategoryList')
// console.log('打印这个',reqCategoryListData());

//获取轮播图数据
export const reqBannerListData = () => mockAjax.get('/banner')

//获取楼层
export const reqFloorsListData = () => mockAjax.get('/floors')

//获取搜索数据
export const reqSearchInfoData = (searchParams) => ajax.post('/list', searchParams)

//获取商品详情数据
export const reqGoodDetailInfoData = (id) => ajax.get(`/item/${id}`)

//添加到购物车
export const reqAddOrUpdateCart = (skuId, skuNum) => ajax.post(`/cart/addToCart/${skuId}/${skuNum}`)

//发送获取购物车中的商品数据
export const reqShopCartListData = () => ajax.get(`/cart/cartList`)

// 更改服务器端购物车中商品的选中与否的状态

export const reqChangeShopCartInfoState = (skuID, isChecked) => ajax.get(`/cart/checkCart/${skuID}/${isChecked}`)

//删除一件购物车的商品
export const reqDelOnShopCartInfo = (skuId) => ajax.delete(`/cart/deleteCart/${skuId}`)

// 11. 获取验证码的请求
export const reqCodeUserInfo = (phone) => {
    return ajax({
        url: `user/passport/sendCode/${phone}`,
        method: 'get'
    })
}




//12.批量删除购物车中选中的商品
export const reqDelSelectedCartInfo = (cartInfo) => ajax.delete('/cart/batchDeleteCart', cartInfo)

// 13. 实现用户注册
export const reqRegisterUserInfo = (user) => {
    return ajax({
        url: '/user/passport/register',
        method: 'post',
        data: user
    })
}

// 14. 实现登陆
export const reqUserLogin = (user) => {
    return ajax({
        url: '/user/passport/login',
        method: 'post',
        data: user
    })
}

//根据token获取用户信息
export const reqUserToken = () => {
    return ajax({
        url: '/user/passport/auth/getUserInfo',
        method: 'get'
    })
}


// 15. 用户登出
export const reqUserLogout = () => {
    return ajax({
        url: 'user/passport/logout',
        method: 'get'
    })
}

//获取用户收货地址信息
export const reqUserAddressInfo = () => {
    return ajax({
        url: 'user/userAddress/auth/findUserAddressList',
        method: 'get'
    })
}



//获取用户交易页面信息
export const reqUserTradeInfo = () => {
    return ajax({
        url: 'order/auth/trade',
        method: 'get'
    })
}


//提交订单
export const reqSubmitUserOrder = (tradeNo, userOrderInfo) => {
    return ajax({
        url: `order/auth/submitOrder?tradeNo=${tradeNo}`,
        method: 'post',
        data: userOrderInfo
    })
}
//获取订单支付信息
export const reqUserOrderPayInfo = (orderId) => {
    return ajax({
        url: `payment/weixin/createNative/${orderId}`,
        method: "get"
    })
}
//获取查询支付订单状态
export const reqUserOrderPayState = (orderId) => {
    return ajax({
        url: `payment/weixin/queryPayStatus/${orderId}`,
        method: 'get'
    })
}
//获取订单列表信息
export const reqMyOrderInfo = (page, limit) => {
    return ajax({
        url: `/order/auth/${page}/${limit}`,
        method: 'get'
    })
}

//